import cTitle from 'components/title';
import { Toast } from 'vant';

export default {
  data() {
    return {
      all_amount: [],
      earningsImg:'',
      imgPath:'',
    };
  },
  activated() {
    this.getData();
  },
  methods: {
    toEarningList(item) {
      this.$router.push(this.fun.getUrl('earningList', {}, {plugin_type: item.type,plugin_text:item.title}));
    },
    getData() {
      const that = this;
      $http.get("finance.plugin-settle.plugin-list", {basic_info:1}, "...").then(response => {
        if (response.result === 1) {
          this.imgPath = response.basic_info.host;
          this.earningsImg = `${this.imgPath}earning/my-earnings.png`;
          that.all_amount = response.data;

          that.all_amount.map((item,index) => {
            this.$set(item, 'url', `${that.imgPath}earning/` + that.getTypeIcon(item.type));
          })
          console.log(that.all_amount);
        }
      }).catch(error => {
        Toast(error);
      });
    },
    getTypeIcon(type) {
      const iconMap = {
        commission: 'distribution.png',
        areaDividend: 'area-icon.png',
        merchant: 'dealer-icon.png',
        teamDividend: 'earnings-icon.png',
        default: 'week-icon.png',
        zhixianggouMerchantReward:"zhixianggou-02.png",
        zhixianggouRefereeReward:"zhixianggou-02.png"
      };
      return iconMap[type] || iconMap.default;
    }
  },
  components: {cTitle}
};